//
//  EvaluateSectionHeaderView.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/18.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "EvaluateSectionHeaderView.h"

@implementation EvaluateSectionHeaderView

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.userIcon pp_clipCorners:UIRectCornerAllCorners radius:self.userIcon.frame.size.height/2];
    });
}

+(CGFloat)calculateHWithModel:(CommunityInteractionModel *)model {

    NSString *content = @"";
    
    if ([model.level isEqualToString:@"2"]) {
        content = model.commentContent;
    }
    
    if ([model.level isEqualToString:@"3"]) {
        content = model.replyContent;
    }
    
    if ([model.level isEqualToString:@"4"]) {
        content = model.replyNextContent;
    }
    
    CGFloat labHeight = [Utilities getStringHeightWithText:content font:[UIFont systemFontOfSize:14] viewWidth:(TTScreenWidth-78)];
    return 60 + labHeight + 10;
}

- (void)fillWithModel:(CommunityInteractionModel *)model {
    
    [self.userIcon sd_setImageWithURL:[NSURL URLWithString:model.replyUserHeadUrl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.userName.text = model.replyUserNickName;
    
    self.evaContentLab.text = @"";
    
    if ([model.level isEqualToString:@"2"]) {
        self.evaContentLab.text = model.commentContent;
    }
    
    //level为3的时候为60
    if ([model.level isEqualToString:@"3"]) {
        self.evaContentLab.text = model.replyContent;
    }
    
    if ([model.level isEqualToString:@"4"]) {
        self.evaContentLab.text = model.replyNextContent;
    }
    
}


- (IBAction)deleteAction:(id)sender {
    if (self.EvaluateDeleteBlock) {
        self.EvaluateDeleteBlock();
    }
}


@end
